/**
 * 
 */
package candy;

import java.io.Serializable;

/**
 * @author 
 *
 */
public class Cookies extends Sweet implements Serializable{

	
	protected double rateOfFlour;
	
	public Cookies(int id, String name, double albumens, double fats,
			double carbohydrates, double weight, double price, double rateOfFlour) {
		super(id, name, albumens, fats, carbohydrates, weight, price);
		this.rateOfFlour = rateOfFlour;
	}

	@Override
	protected double calculateCalorificValue() {
		return 6.35*(this.getAlbumens()+this.getCarbohydrates()+this.getFats());
	}

	public double getRateOfFlour() {
		return rateOfFlour;
	}

	public void setRateOfFlour(double rateOfFlour) {
		this.rateOfFlour = rateOfFlour;
	}

	@Override
	public String toString() {
		return "Cookies # " + id + name + "\n"
				+ " albumens = " + albumens + " carbohydrates = " + carbohydrates
				+ "\n" 	+ "fats = " + fats 
				+ "\n" + " rate of flour" + rateOfFlour
				+ "calculateCalorificValue = "+ calculateCalorificValue()
				+ "\n" + " price=" + price + " weight=" + weight 
				+ "\n" + "-----------"	;				
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		long temp;
		temp = Double.doubleToLongBits(rateOfFlour);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (!super.equals(obj)) {
			return false;
		}
		if (!(obj instanceof Cookies)) {
			return false;
		}
		Cookies other = (Cookies) obj;
		if (Double.doubleToLongBits(rateOfFlour) != Double
				.doubleToLongBits(other.rateOfFlour)) {
			return false;
		}
		return true;
	}

}
